/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.service.impl;

import cn.hutool.core.util.ObjectUtil;
import org.springblade.common.cache.DictCache;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.dto.BuildingFloorElevatorDTO;
import org.springblade.modules.admin.entity.BuildingFloorElevator;
import org.springblade.modules.admin.vo.BuildingElevatorTemplateVO;
import org.springblade.modules.admin.vo.BuildingFloorElevatorVO;
import org.springblade.modules.admin.mapper.BuildingFloorElevatorMapper;
import org.springblade.modules.admin.service.IBuildingFloorElevatorService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.admin.vo.ProjectVO;
import org.springblade.modules.admin.vo.plan.AffairListVo;
import org.springblade.modules.system.entity.Dict;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 *  服务实现类
 *
 * @author ysq
 * @since 2024-07-24
 */
@Service
public class BuildingFloorElevatorServiceImpl extends BaseServiceImpl<BuildingFloorElevatorMapper, BuildingFloorElevator> implements IBuildingFloorElevatorService {
	/**
	 * 小区类型字典码
	 */
	String PROJECT_TYPE_CODE = "building_type";


	@Override
	public IPage<ProjectVO> pageList(BuildingFloorElevatorDTO BuildingFloorElevatorDTO) {
		Query query = new Query();
		query.setSize(BuildingFloorElevatorDTO.getSize());
		query.setCurrent(BuildingFloorElevatorDTO.getCurrent());
		IPage<ProjectVO> page = Condition.getPage(query);
		List<ProjectVO> pageList = baseMapper.pageList(page, BuildingFloorElevatorDTO);
		page.setRecords(pageList);
		List<Dict> dictList = DictCache.getList(PROJECT_TYPE_CODE);
		Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(Dict::getDictKey, Dict::getDictValue));
		for (int i = 0; i < pageList.size(); i++) {
			pageList.get(i).setTypeName(dictMap.get(pageList.get(i).getType()));
		}
		return page;
	}

}
